const js2xmlparser = require('js2xmlparser');
module.exports = {
    enable: true,
    handle: function (message, ctx) {
        let content = message.Content[0];
        let toUserName = message.ToUserName[0];
        let fromUserName = message.FromUserName[0];
        let openid = ctx.query.openid;

        if (content !== undefined && content.indexOf('3306') !== -1) {
            console.log("Try to get a location record!");
            let responseContent = {};
            responseContent.MsgType = 'text';
            responseContent.ToUserName = openid;
            responseContent.FromUserName = toUserName;
            responseContent.CreateTime = parseInt(new Date().getTime()/1000);
            responseContent.Content = 'http://weixin.wenxin-zhang.cn'
            let responseContentXml = js2xmlparser.parse("xml",responseContent);
            ctx.body = responseContentXml;
            console.log(responseContentXml)
        }
    }
}